<?php

namespace SunAdmin\Controller;

use SunAdmin\Common\ResponseJson;
use SunAdmin\Service\MenusService;

class MenusController
{
    public function getAllMenus()
    {
        //仅允许超级管理员
        if (!request()->adminUser->is_administrators) {
            return ResponseJson::error("仅允许超级管理员操作");
        }

        $res = menusService::getAllMenus(request()->adminUid);
        return ResponseJson::success($res);
    }

    public function edit()
    {
        $data = request()->post();
        menusService::edit($data);
        return ResponseJson::success();
    }

    public function deleteMenus($menusId)
    {
        if (!request()->adminUser->is_administrators) {
            return ResponseJson::error("仅允许超级管理员操作");
        }
        menusService::deleteMenus($menusId);
        return ResponseJson::success();
    }
}